//
//  RootTabBarController.m
//  网易新闻
//
//  Created by 王宇先 on 16/4/8.
//  Copyright © 2016年 王宇先. All rights reserved.
//

#import "RootTabBarController.h"
#import "ViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
#import "FourthViewController.h"
#import "FivthViewController.h"
#import "NaviOfFirstViewController.h"
#import "NaviOfSecondViewController.h"
#import "NaviOfThirdViewController.h"
#import "NaviOfFourthViewController.h"
#import "NaviOfFivthViewController.h"

@interface RootTabBarController ()

@end

@implementation RootTabBarController
#pragma mark - 重写
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // 设置root的viewControllers属性.
        self.viewControllers = [self createRootOfVCs];
    }
    return self;
}
#pragma mark - 创建根试图
- (NSArray<UIViewController *> *)createRootOfVCs {
    NSMutableArray *arrOfVCs = [NSMutableArray array];
    //第一个 Item
    ViewController *vc1 = [[ViewController alloc] init];
    
    NaviOfFirstViewController *navi1 = [[NaviOfFirstViewController alloc] initWithRootViewController:vc1];
    
    [arrOfVCs addObject:navi1];
    // 设置item
    navi1.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"新闻" image:[UIImage imageNamed:@"iconfont-xinwen"] tag:100];
    //第二个 Item
    SecondViewController *vc2 = [[SecondViewController alloc] init];
    
    NaviOfSecondViewController *navi2 = [[NaviOfSecondViewController alloc] initWithRootViewController:vc2];
    
    [arrOfVCs addObject:navi2];
    // 设置item
    navi2.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"阅读" image:[UIImage imageNamed:@"iconfont-book"] tag:200];
    //第三个 Item
    ThirdViewController *vc3 = [[ThirdViewController alloc] init];
    
    NaviOfThirdViewController *navi3 = [[NaviOfThirdViewController alloc] initWithRootViewController:vc3];
    
    [arrOfVCs addObject:navi3];
    // 设置item
    navi3.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"视频" image:[UIImage imageNamed:@"iconfont-quansan"] tag:300];
    //第四个 item
    FourthViewController *vc4 = [[FourthViewController alloc] init];
    NaviOfFourthViewController *navi4 = [[NaviOfFourthViewController alloc] initWithRootViewController:vc4];
    [arrOfVCs addObject:navi4];
    //设置 item
    navi4.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"话题" image:[UIImage imageNamed:@"iconfont-quansan"] tag:400];
    //第五个 item
    FivthViewController *vc5 = [[FivthViewController alloc] init];
    NaviOfFivthViewController *navi5 = [[NaviOfFivthViewController alloc] initWithRootViewController:vc5];
    [arrOfVCs addObject:navi5];
    //设置 item
    navi5.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我" image:[UIImage imageNamed:@"iconfont-wode"] tag:500];
    
    
    return arrOfVCs;
}




#pragma mark - other
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
